package com.wcar.system.controller;

import com.wcar.common.entity.Menu;
import com.wcar.common.vo.Result;
import com.wcar.system.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
	@Autowired
	private MenuService menuService;

	@GetMapping("/queryTreeDateByUserId")
	public Result<List<Menu>> queryTreeByUserId() {
		return menuService.getMenuByUserId();
	}

	@GetMapping("/api/selectAll")
	public Result<List<Menu>> queryTreeByUser() {
		return menuService.getMenuByUser();
	}

	@PostMapping("/api/addMenu")
	public Result addMenu(@RequestBody Menu menu) {
		return menuService.addMenu(menu);
	}

	@PutMapping("/api/updateMenu")
	public Result updateMenu(@RequestBody Menu menu) {
		return menuService.updateMenu(menu);
	}

	@DeleteMapping("api/deleteMenu/{menuId}")
	public Result deleteMenu(@PathVariable Integer menuId) {
		return menuService.deleteMenu(menuId);
	}
    @GetMapping("/selectAll")
    public Result<List<Menu>> selectAll() {
        return menuService.selectAll();
    }

}
